home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / c++ / ostream.z / ostream
Encoding:
Text File  |  2002-10-03  |  18.2 KB  |  268 lines

  1. OSTREAM(3C)                                            Last changed: 1-7-99
  2.  
  3.  
  4. NNAAMMEE
  5.      oossttrreeaamm - Formatted and unformatted output
  6.  
  7. SSYYNNOOPPSSIISS
  8.      ##iinncclluuddee <<iioossttrreeaamm..hh>>
  9.  
  10.      ttyyppeeddeeff lloonngg ssttrreeaammooffff,, ssttrreeaammppooss;;
  11.      ccllaassss iiooss {{
  12.      ppuubblliicc::
  13.           eennuumm sseeeekk__ddiirr {{ bbeegg,, ccuurr,, eenndd }};;
  14.           eennuumm ooppeenn__mmooddee {{ iinn,, oouutt,, aattee,, aapppp,, ttrruunncc,, nnooccrreeaattee,, nnoorreeppllaaccee }}
  15.      ;;
  16.           eennuumm {{ sskkiippwwss==0011,,
  17.                  lleefftt==0022,,  rriigghhtt==0044,, iinntteerrnnaall==001100,,
  18.                  ddeecc==002200,, oocctt==004400,, hheexx==00110000,,
  19.                  sshhoowwbbaassee==00220000,, sshhoowwppooiinntt==00440000,, uuppppeerrccaassee==0011000000,,
  20.      sshhoowwppooss==0022000000,,
  21.                  sscciieennttiiffiicc==0044000000,, ffiixxeedd==001100000000,,
  22.                  uunniittbbuuff==002200000000,, ssttddiioo==004400000000 }};;
  23.           //// aanndd lloottss ooff ootthheerr ssttuuffff,, sseeee iiooss((33CC)) ......
  24.      }} ;;
  25.  
  26.      ccllaassss oossttrreeaamm :: ppuubblliicc iiooss {{
  27.      ppuubblliicc::
  28.                oossttrreeaamm((ssttrreeaammbbuuff**));;
  29.           oossttrreeaamm&&  fflluusshh(());;
  30.           iinntt  ooppffxx(());;
  31.           oossttrreeaamm&&  ppuutt((cchhaarr));;
  32.           oossttrreeaamm&&  sseeeekkpp((ssttrreeaammppooss));;
  33.           oossttrreeaamm&&  sseeeekkpp((ssttrreeaammooffff,, sseeeekk__ddiirr));;
  34.           ssttrreeaammppooss tteellllpp(());;
  35.           oossttrreeaamm&&  wwrriittee((ccoonnsstt cchhaarr** ppttrr,, iinntt nn));;
  36.           oossttrreeaamm&&  wwrriittee((ccoonnsstt uunnssiiggnneedd cchhaarr** ppttrr,, iinntt nn));;
  37.           oossttrreeaamm&&  ooppeerraattoorr<<<<((ccoonnsstt cchhaarr**));;
  38.           oossttrreeaamm&&  ooppeerraattoorr<<<<((cchhaarr));;
  39.           oossttrreeaamm&&  ooppeerraattoorr<<<<((sshhoorrtt));;
  40.           oossttrreeaamm&&  ooppeerraattoorr<<<<((iinntt));;
  41.           oossttrreeaamm&&  ooppeerraattoorr<<<<((lloonngg));;
  42.           oossttrreeaamm&&  ooppeerraattoorr<<<<((ffllooaatt));;
  43.           oossttrreeaamm&&  ooppeerraattoorr<<<<((ddoouubbllee));;
  44.           oossttrreeaamm&&  ooppeerraattoorr<<<<((uunnssiiggnneedd cchhaarr));;
  45.           oossttrreeaamm&&  ooppeerraattoorr<<<<((uunnssiiggnneedd sshhoorrtt));;
  46.           oossttrreeaamm&&  ooppeerraattoorr<<<<((uunnssiiggnneedd iinntt));;
  47.           oossttrreeaamm&&  ooppeerraattoorr<<<<((uunnssiiggnneedd lloonngg));;
  48.           oossttrreeaamm&&  ooppeerraattoorr<<<<((vvooiidd**));;
  49.           oossttrreeaamm&&  ooppeerraattoorr<<<<((ssttrreeaammbbuuff**));;
  50.           oossttrreeaamm&&  ooppeerraattoorr<<<<((oossttrreeaamm&& ((**))((oossttrreeaamm&&))));;
  51.           oossttrreeaamm&&  ooppeerraattoorr<<<<((iiooss&& ((**))((iiooss&&))));;
  52.      }};;
  53.  
  54.      ccllaassss oossttrreeaamm__wwiitthhaassssiiggnn {{
  55.                oossttrreeaamm__wwiitthhaassssiiggnn(());;
  56.           iissttrreeaamm&&  ooppeerraattoorr==((iissttrreeaamm&&));;
  57.           iissttrreeaamm&&  ooppeerraattoorr==((ssttrreeaammbbuuff**));;
  58.      }};;
  59.  
  60.      eexxtteerrnn oossttrreeaamm__wwiitthhaassssiiggnn ccoouutt;;
  61.      eexxtteerrnn oossttrreeaamm__wwiitthhaassssiiggnn cceerrrr;;
  62.      eexxtteerrnn oossttrreeaamm__wwiitthhaassssiiggnn cclloogg;;
  63.  
  64.      oossttrreeaamm&&  eennddll((oossttrreeaamm&&)) ;;
  65.      oossttrreeaamm&&  eennddss((oossttrreeaamm&&)) ;;
  66.      oossttrreeaamm&&  fflluusshh((oossttrreeaamm&&)) ;;
  67.      iiooss&& ddeecc((iiooss&&)) ;;
  68.      iiooss&& hheexx((iiooss&&)) ;;
  69.      iiooss&& oocctt((iiooss&&)) ;;
  70.  
  71. IIMMPPLLEEMMEENNTTAATTIIOONN
  72.      IRIX systems
  73.  
  74. DDEESSCCRRIIPPTTIIOONN
  75.      oossttrreeaamm supports insertion (storing) into a ssttrreeaammbbuuff.  This is
  76.      commonly referred to as an output operation.
  77.  
  78.      In the following descriptions of oossttrreeaamm member functions and related
  79.      functions, assume the following:
  80.  
  81.      * _o_u_t_s is an oossttrreeaamm.
  82.  
  83.      * _o_u_t_s_w_a is an oossttrreeaamm__wwiitthhaassssiiggnn.
  84.  
  85.      * _o_u_t_s_p is an oossttrreeaamm**.
  86.  
  87.      * _c is a cchhaarr.
  88.  
  89.      * _p_t_r is a cchhaarr** or uunnssiiggnneedd cchhaarr**.
  90.  
  91.      * _s_b is a ssttrreeaammbbuuff**
  92.  
  93.      * _i and _n are iinntts.
  94.  
  95.      * _p_o_s is a ssttrreeaammppooss.
  96.  
  97.      * _o_f_f is a ssttrreeaammooffff.
  98.  
  99.      * _d_i_r is a sseeeekk__ddiirr.
  100.  
  101.      * _m_a_n_i_p is a function with type oossttrreeaamm&& ((**))((oossttrreeaamm&&)).
  102.  
  103.    CCoonnssttrruuccttoorrss aanndd AAssssiiggnnmmeenntt
  104.      oossttrreeaamm((_s_b))
  105.           initializes iiooss state variables and associates buffer _s_b with the
  106.           oossttrreeaamm.
  107.  
  108.      oossttrreeaamm__wwiitthhaassssiiggnn(())
  109.           Does no initialization.  This allows a file static variable of
  110.           this type (ccoouutt, for example) to be used before it is
  111.           constructed, provided it is assigned to first.
  112.  
  113.      _o_u_t_s_w_a==_s_b
  114.           Associates _s_b with _s_w_a and initializes the entire state of
  115.           _o_u_t_s_w_a.
  116.  
  117.      _i_n_s_w_a==_i_n_s
  118.           Associates _i_n_s-->>rrddbbuuff(()) _w_i_t_h _s_w_a _a_n_d _i_n_i_t_i_a_l_i_z_e_s _t_h_e _e_n_t_i_r_e _s_t_a_t_e
  119.           _o_f _o_u_t_s_w_a.
  120.  
  121.    OOuuttppuutt pprreeffiixx ffuunnccttiioonn::
  122.      _i==_o_u_t_s..ooppffxx(())
  123.           If _o_u_t_s's error state is nonzero, returns immediately.  If
  124.           _o_u_t_s..ttiiee(()) _i_s _n_o_n-_n_u_l_l, _i_t _i_s _f_l_u_s_h_e_d.  _R_e_t_u_r_n_s _n_o_n-_z_e_r_o _e_x_c_e_p_t
  125.           _w_h_e_n _o_u_t_s'_s _e_r_r_o_r _s_t_a_t_e _i_s _n_o_n_z_e_r_o.
  126.  
  127.    OOuuttppuutt ssuuffffiixx ffuunnccttiioonn
  128.      oossffxx(())
  129.           Performs ``suffix'' actions before returning from inserters.  If
  130.           iiooss::::uunniittbbuuff is set, oossffxx(()) flushes the oossttrreeaamm.  If iiooss::::ssttddiioo
  131.           is set, oossffxx(()) flushes ssttddoouutt and ssttddeerrrr.
  132.  
  133.      oossffxx(()) is called by all predefined inserters, and should be called by
  134.      user-defined inserters as well, after any direct manipulation of the
  135.      ssttrreeaammbbuuff.  It is not called by the binary output functions.
  136.  
  137.    FFoorrmmaatttteedd OOuuttppuutt FFuunnccttiioonnss ((iinnsseerrtteerrss))
  138.      _o_u_t_s<<<<_x
  139.           First calls _o_u_t_s..ooppffxx(()) _a_n_d _i_f _t_h_a_t _r_e_t_u_r_n_s _0, _d_o_e_s _n_o_t_h_i_n_g.
  140.           _O_t_h_e_r_w_i_s_e _i_n_s_e_r_t_s _a _s_e_q_u_e_n_c_e _o_f _c_h_a_r_a_c_t_e_r_s _r_e_p_r_e_s_e_n_t_i_n_g _x _i_n_t_o
  141.           _o_u_t_s..rrddbbuuff(()).  _E_r_r_o_r_s _a_r_e _i_n_d_i_c_a_t_e_d _b_y _s_e_t_t_i_n_g _t_h_e _e_r_r_o_r _s_t_a_t_e _o_f
  142.           _o_u_t_s.  _o_u_t_s _i_s _a_l_w_a_y_s _r_e_t_u_r_n_e_d.
  143.  
  144.           _x is converted into a sequence of characters (its representation)
  145.           according to rules that depend on _x's type and _o_u_t_s's format
  146.           state flags and variables (see iiooss(3C)).  Inserters are defined
  147.           for the following types, with conversion rules as described
  148.           below:
  149.  
  150.           cchhaarr**
  151.                The representation is the sequence of characters up to (but
  152.                not including) the terminating null of the string _x points
  153.                at.
  154.  
  155.           _a_n_y _i_n_t_e_g_r_a_l _t_y_p_e except cchhaarr _a_n_d uunnssiiggnneedd cchhaarr
  156.                If _x is positive the representation contains a sequence of
  157.                decimal, octal, or hexadecimal digits with no leading zeros
  158.                according to whether iiooss::::ddeecc, iiooss::::oocctt, or iiooss::::hheexx,
  159.                respectively, is set in iiooss's format flags.  If none of
  160.                those flags are set, conversion defaults to decimal.  If _x
  161.                is zero, the representation is a single zero character(00).
  162.                If _x is negative, decimal conversion converts it to a minus
  163.                sign (--) followed by decimal digits.  If _x is positive and
  164.                iiooss::::sshhoowwppooss is set, decimal conversion converts it to a
  165.                plus sign (++) followed by decimal digits.  The other
  166.                conversions treat all values as unsigned.  If iiooss::::sshhoowwbbaassee
  167.                is set in _i_o_s's format flags, the hexadecimal representation
  168.                contains 00xx before the hexadecimal digits, or 00XX if
  169.                iiooss::::uuppppeerrccaassee is set.  If iiooss::::sshhoowwbbaassee is set, the octal
  170.                representation contains a leading 0.
  171.  
  172.           vvooiidd**
  173.                Pointers are converted to integral values and then converted
  174.                to hexadecimal numbers as if iiooss::::sshhoowwbbaassee were set.
  175.  
  176.           ffllooaatt, ddoouubbllee
  177.                The arguments are converted according to the current values
  178.                of _o_u_t_s..pprreecciissiioonn(()), _o_u_t_s..wwiiddtthh(()) _a_n_d _o_u_t_s'_s _f_o_r_m_a_t _f_l_a_g_s
  179.                iiooss::::sscciieennttiiffiicc, iiooss::::ffiixxeedd, _a_n_d iiooss::::uuppppeerrccaassee.  (_S_e_e
  180.                iiooss(_3_C).)  _T_h_e _d_e_f_a_u_l_t _v_a_l_u_e _f_o_r _o_u_t_s..pprreecciissiioonn(()) _i_s _6.  _I_f
  181.                _n_e_i_t_h_e_r iiooss::::sscciieennttiiffiicc _n_o_r iiooss::::ffiixxeedd _i_s _s_e_t, _e_i_t_h_e_r _f_i_x_e_d
  182.                _o_r _s_c_i_e_n_t_i_f_i_c _n_o_t_a_t_i_o_n _i_s _c_h_o_s_e_n _f_o_r _t_h_e _r_e_p_r_e_s_e_n_t_a_t_i_o_n,
  183.                _d_e_p_e_n_d_i_n_g _o_n _t_h_e _v_a_l_u_e _o_f _x.
  184.  
  185.           cchhaarr, uunnssiiggnneedd cchhaarr
  186.                No special conversion is necessary.
  187.  
  188.           After the representation is determined, padding occurs.  If
  189.           _o_u_t_s..wwiiddtthh(()) _i_s _g_r_e_a_t_e_r _t_h_a_n _0 _a_n_d _t_h_e _r_e_p_r_e_s_e_n_t_a_t_i_o_n _c_o_n_t_a_i_n_s
  190.           _f_e_w_e_r _t_h_a_n _o_u_t_s..wwiiddtthh(()) _c_h_a_r_a_c_t_e_r_s, _t_h_e_n _e_n_o_u_g_h _o_u_t_s..ffiillll(())
  191.           _c_h_a_r_a_c_t_e_r_s _a_r_e _a_d_d_e_d _t_o _b_r_i_n_g _t_h_e _t_o_t_a_l _n_u_m_b_e_r _o_f _c_h_a_r_a_c_t_e_r_s _t_o
  192.           iiooss..wwiiddtthh(()).  _I_f iiooss::::lleefftt _i_s _s_e_t _i_n iiooss'_s _f_o_r_m_a_t _f_l_a_g_s, _t_h_e
  193.           _s_e_q_u_e_n_c_e _i_s _l_e_f_t-_a_d_j_u_s_t_e_d, _t_h_a_t _i_s, _c_h_a_r_a_c_t_e_r_s _a_r_e _a_d_d_e_d _a_f_t_e_r
  194.           _t_h_e _c_h_a_r_a_c_t_e_r_s _d_e_t_e_r_m_i_n_e_d _a_b_o_v_e.  _I_f iiooss::::rriigghhtt _i_s _s_e_t, _t_h_e
  195.           _p_a_d_d_i_n_g _i_s _a_d_d_e_d _b_e_f_o_r_e _t_h_e _c_h_a_r_a_c_t_e_r_s _d_e_t_e_r_m_i_n_e_d _a_b_o_v_e.  _I_f
  196.           iiooss::::iinntteerrnnaall _i_s _s_e_t, _t_h_e _p_a_d_d_i_n_g _i_s _a_d_d_e_d _a_f_t_e_r _a_n_y _l_e_a_d_i_n_g _s_i_g_n
  197.           _o_r _b_a_s_e _i_n_d_i_c_a_t_i_o_n _a_n_d _b_e_f_o_r_e _t_h_e _c_h_a_r_a_c_t_e_r_s _t_h_a_t _r_e_p_r_e_s_e_n_t _t_h_e
  198.           _v_a_l_u_e.  iiooss..wwiiddtthh(()) _i_s _r_e_s_e_t _t_o _0, _b_u_t _a_l_l _o_t_h_e_r _f_o_r_m_a_t _v_a_r_i_a_b_l_e_s
  199.           _a_r_e _u_n_c_h_a_n_g_e_d.  _T_h_e _r_e_s_u_l_t_i_n_g _s_e_q_u_e_n_c_e (_p_a_d_d_i_n_g _p_l_u_s
  200.           _r_e_p_r_e_s_e_n_t_a_t_i_o_n) _i_s _i_n_s_e_r_t_e_d _i_n_t_o _o_u_t_s..rrddbbuuff(()).
  201.  
  202.      _o_u_t_s<<<<_s_b
  203.           If _o_u_t_s..ooppffxx(()) _r_e_t_u_r_n_s _n_o_n-_z_e_r_o, _t_h_e _s_e_q_u_e_n_c_e _o_f _c_h_a_r_a_c_t_e_r_s _t_h_a_t
  204.           _c_a_n _b_e _f_e_t_c_h_e_d _f_r_o_m _s_b _a_r_e _i_n_s_e_r_t_e_d _i_n_t_o _o_u_t_s..rrddbbuuff(()).  _I_n_s_e_r_t_i_o_n
  205.           _s_t_o_p_s _w_h_e_n _n_o _m_o_r_e _c_h_a_r_a_c_t_e_r_s _c_a_n _b_e _f_e_t_c_h_e_d _f_r_o_m _s_b.  _N_o _p_a_d_d_i_n_g
  206.           _i_s _p_e_r_f_o_r_m_e_d.  _A_l_w_a_y_s _r_e_t_u_r_n_s _o_u_t_s.
  207.  
  208.    UUnnffoorrmmaatttteedd OOuuttppuutt FFuunnccttiioonnss
  209.      _o_u_t_s_p==&&_o_u_t_s..ppuutt((cc))
  210.           Inserts _c into _o_u_t_s..rrddbbuuff(()).  _S_e_t_s _t_h_e _e_r_r_o_r _s_t_a_t_e _i_f _t_h_e
  211.           _i_n_s_e_r_t_i_o_n _f_a_i_l_s.
  212.  
  213.      _o_u_t_s_p==&&_o_u_t_s..wwrriittee((_s,,_n))
  214.           Inserts the _n characters starting at _s into _o_u_t_s..rrddbbuuff(()).  _T_h_e_s_e
  215.           _c_h_a_r_a_c_t_e_r_s _m_a_y _i_n_c_l_u_d_e _z_e_r_o_s (_i._e., _s _n_e_e_d _n_o_t _b_e _a _n_u_l_l
  216.           _t_e_r_m_i_n_a_t_e_d _s_t_r_i_n_g).
  217.  
  218.    OOtthheerr MMeemmbbeerr FFuunnccttiioonnss
  219.      _o_u_t_s_p==&&_o_u_t_s..fflluusshh(())
  220.           Storing characters into a streambuf does not always cause them to
  221.           be consumed (e.g., written to the external file) immediately.
  222.           fflluusshh(()) causes any characters that may have been stored but not
  223.           yet consumed to be consumed by calling _o_u_t_s..rrddbbuuff(())-->>ssyynncc.
  224.  
  225.      _o_u_t_s<<<<mmaanniipp
  226.           Equivalent to mmaanniipp((_o_u_t_s)).  _S_y_n_t_a_c_t_i_c_a_l_l_y _t_h_i_s _l_o_o_k_s _l_i_k_e _a_n
  227.           _i_n_s_e_r_t_i_o_n _o_p_e_r_a_t_i_o_n, _b_u_t _s_e_m_a_n_t_i_c_a_l_l_y _i_t _d_o_e_s _a_n _a_r_b_i_t_r_a_r_y
  228.           _o_p_e_r_a_t_i_o_n _r_a_t_h_e_r _t_h_a_n _c_o_n_v_e_r_t_i_n_g mmaanniipp _t_o _a _s_e_q_u_e_n_c_e _o_f
  229.           _c_h_a_r_a_c_t_e_r_s _a_s _d_o _t_h_e _i_n_s_e_r_t_i_o_n _o_p_e_r_a_t_o_r_s.  _P_r_e_d_e_f_i_n_e_d
  230.           _m_a_n_i_p_u_l_a_t_o_r_s _a_r_e _d_e_s_c_r_i_b_e_d _b_e_l_o_w.
  231.  
  232.    PPoossiittiioonniinngg FFuunnccttiioonnss
  233.      _o_u_t_s_p==&&_i_n_s..sseeeekkpp((_o_f_f,,_d_i_r))
  234.           Repositions _o_u_t_s..rrddbbuuff(())'_s _p_u_t _p_o_i_n_t_e_r.  _S_e_e ssbbuuff..ppuubb(_3_C) _f_o_r _a
  235.           _d_i_s_c_u_s_s_i_o_n _o_f _p_o_s_i_t_i_o_n_i_n_g.
  236.  
  237.      _o_u_t_s_p==&&_o_u_t_s..sseeeekkpp((_p_o_s))
  238.           Repositions _o_u_t_s..rrddbbuuff(())'_s _p_u_t _p_o_i_n_t_e_r.  _S_e_e ssbbuuff..ppuubb(_3_C) _f_o_r _a
  239.           _d_i_s_c_u_s_s_i_o_n _o_f _p_o_s_i_t_i_o_n_i_n_g.
  240.  
  241.      _p_o_s==_o_u_t_s..tteellllpp(())
  242.           The current position of _o_u_t_s..rrddbbuuff(())'_s _p_u_t _p_o_i_n_t_e_r.  _S_e_e
  243.           ssbbuuff..ppuubb(_3_C) _f_o_r _a _d_i_s_c_u_s_s_i_o_n _o_f _p_o_s_i_t_i_o_n_i_n_g.
  244.  
  245.    MMaanniippuullaattoorrss
  246.      _o_u_t_s<<<<eennddll
  247.           Ends a line by inserting a newline character and flushing.
  248.  
  249.      _o_u_t_s<<<<eennddss
  250.           Ends a string by inserting a null (0) character.
  251.  
  252.      _o_u_t_s<<<<fflluusshh
  253.           Flushes _o_u_t_s.
  254.  
  255.      _o_u_t_s<<<<ddeecc
  256.           Sets the conversion base format flag to 10.  See iiooss(3C).
  257.  
  258.      _o_u_t_s<<<<hheexx
  259.           Sets the conversion base format flag to 16.  See iiooss(3C).
  260.  
  261.      _o_u_t_s<<<<oocctt
  262.           Sets the conversion base format flag to 8.  See iiooss(3C).
  263.  
  264. SSEEEE AALLSSOO
  265.      iiooss(3C), ssbbuuff..ppuubb(3C), mmaanniipp(3C)
  266.  
  267.      This man page is available only online.
  268.